<?php

use Illuminate\Database\Seeder;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        collect([
            [
                'id'              => '100000',    // 默认用户
                'mobile'          => '13100000000',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王大',
                'reg_ip'          => '127.0.0.1',
                'pay_password'    => bcrypt('123123a'),
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
            [
                'id'              => '100001',    // 默认用户
                'mobile'          => '13100000001',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王一',
                'pay_password'    => bcrypt('123123a'),
                'reg_ip'          => '127.0.0.1',
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
            [
                'id'              => '100002',    // 默认用户
                'mobile'          => '13100000002',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王二',
                'reg_ip'          => '127.0.0.1',
                'pay_password'    => bcrypt('123123a'),
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
            [
                'id'              => '100003',    // 默认用户
                'mobile'          => '13100000003',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王三',
                'pay_password'    => bcrypt('123123a'),
                'reg_ip'          => '127.0.0.1',
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
            [
                'id'              => '100004',    // 默认用户
                'mobile'          => '13100000004',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王四',
                'reg_ip'          => '127.0.0.1',
                'pay_password'    => bcrypt('123123a'),
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
            [
                'id'              => '100005',    // 默认用户
                'mobile'          => '13100000005',
                'roles'           => 'buyer,seller',
                'password'        => bcrypt('123123a'),
                'enable'          => '1',
                'name'            => '王五',
                'pay_password'    => bcrypt('123123a'),
                'reg_ip'          => '127.0.0.1',
                'reg_client'      => 'web',
                'authentications' => 'idcard',
            ],
        ])->tap(function ($configs) {
            $this->command->getOutput()->progressStart($configs->count() + 1);
            $this->command->getOutput()->progressAdvance();
        })->each(function ($item) {
            \App\Models\User::updateOrCreate(array_only($item, ['id', 'mobile']), $item);
            $this->command->getOutput()->progressAdvance();
        })->tap(function () {
            $this->command->getOutput()->progressFinish();
        });
    }
}
